//
//  NSString+WebErrorCode.m
//  iAndon_Cloud
//
//  Created by 宣佚 on 14/11/12.
//  Copyright (c) 2014年 刘宣佚. All rights reserved.
//

#import "NSString+WebErrorCode.h"

@implementation NSString (WebErrorCode)

/**
 *  生成错误码信息（根据协议错误码定义）
 *
 *  @return 错误信息字典集
 */
-(NSDictionary *)createBaseWebErrorCodeAndMessage
{
    NSMutableDictionary *errorCodeAndMessage = [[NSMutableDictionary alloc] initWithCapacity:10];
    
    [errorCodeAndMessage setObject:@"用户名或密码错误" forKey:@"201"];
    [errorCodeAndMessage setObject:@"用户名不可以为空" forKey:@"201.3"];
    [errorCodeAndMessage setObject:@"密码不可以为空" forKey:@"201.4"];
    [errorCodeAndMessage setObject:@"用户已离职" forKey:@"202"];
    [errorCodeAndMessage setObject:@"AccessKey错误,请重新登录" forKey:@"210.1"];
    [errorCodeAndMessage setObject:@"AccessKey过期,请重新登录" forKey:@"210.2"];
    [errorCodeAndMessage setObject:@"您无权访问该内容" forKey:@"221"];
    [errorCodeAndMessage setObject:@"上传数据不完整，或格式不正确" forKey:@"230"];
    [errorCodeAndMessage setObject:@"服务器内部错误" forKey:@"500"];
    [errorCodeAndMessage setObject:@"未知错误" forKey:@"999"];
    
    NSDictionary *returnDic = [[NSDictionary alloc] initWithDictionary:errorCodeAndMessage];
    return returnDic;
}

/*!
 *  通过服务器传过来的ResulteMessage返回错误信息
 *
 *  @return 错误信息
 */
-(NSString *)OAErrorCode
{
    NSDictionary *dic = [[NSDictionary alloc] init];
    dic = [self createBaseWebErrorCodeAndMessage];
    
    NSString *errorStr = @"";
    errorStr = dic[self];
    
    return errorStr;
}

@end
